package com.bjpowernode.boss.mvc.model.result;

import com.bjpowernode.boss.enums.ajax.Code;
import lombok.Builder;
import lombok.Data;

/**
 * ajax 统计返回结果集
 */
@Data
@Builder
public class AjaxResult {

    private Integer code;

    private String msg;

    private Object info;

    public static AjaxResult ok(Object data) {
        return AjaxResult
                .builder()
                .code(Code.SUCC.getCode())
                .msg(Code.SUCC.getMsg())
                .info(data)
                .build();
    }

    public static AjaxResult ok() {
        return ok("");
    }

    public static AjaxResult fail(Code code) {
        return AjaxResult.builder()
                .code(code.getCode())
                .msg(code.getMsg())
                .info("")
                .build();
    }

}
